package main

import (
	"fmt"
	"strconv"
)

func putNumber(intChan chan int){
	for i := 1; i <= 20000; i++{
		intChan <- i
	}
	close(intChan)
}


func getNumber(intChan chan int, resChan chan string, finishChan chan bool){
	for index := 0; index < 2500; index ++{
		n := <- intChan
		res := 1
		for i := 2; i <= n; i++{
			res += i
		}
		resChan <- strconv.Itoa(res)
	}
	finishChan <- true
}

func main() {
	intChan := make(chan int, 20000)
	resChan := make(chan string, 20000)
	finishChan := make(chan bool, 8)

	putNumber(intChan)
	for i := 0; i<8; i++{
		go getNumber(intChan, resChan, finishChan)
	}

	for {
		if len(finishChan) == 8{
			break
		}
	}
	close(resChan)
	fmt.Println(len(resChan))
	fmt.Println("----------------")
	for v := range resChan{
		fmt.Println(v)
	}

}